<template>
	<view class="wrap">

		<view class="content">

			<z-paging ref="paging" v-model="dataList" fixed :auto-clean-list-when-reload="false"
				:auto-scroll-to-top-when-reload="false" refresher-threshold="160rpx"
				:refresher-status.sync="refresherStatus" @query="queryList">
				<!-- 小程序中直接修改组件style为position: sticky;无效，需要在组件外层套一层view -->
				<view class="header">
					<view class="name_item">
						<image class="name_logo" src="../../static/images/index/logo.png" mode=""></image>
						<view class="integral">
							<view class="zong" style="font-size: 28rpx;">总积分</view>
							<view class="zong" style="font-size: 36rpx; font-weight: bold;">16800</view>
						</view>
					</view>
					<view class="jifen_item">
						<view class="mingxi" @click="integdetails(3350)">积分明细</view>
					</view>
				</view>
				<view class="content_nav">
					<u-divider color="#28B07C" :fontSize="32">积分兑好礼</u-divider>
				</view>
				<view style="z-index: 100;position: sticky;top :0; margin-top: 30rpx;margin-bottom: 30rpx;">
					<tabs-view @change="tabChange" :items="['全部商品','数码','虚拟物品','家具','家电']"></tabs-view>
				</view>
				<!-- 自定义下拉刷新view -->
				<!-- 注意注意注意！！如果您的项目不是QQ小程序，:status="refresherStatus有更简化的写法，请参阅custom-demo.vue -->

				<custom-refresher slot="refresher" :status="refresherStatus"></custom-refresher>
				<!-- list数据，建议像下方这样在item外层套一个view，而非直接for循环item，因为slot插入有数量限制 -->
				<view style="display: flex; justify-content: space-between; align-items: center;">
					<u-row gutter="16">
						<u-col span="6" v-for="(item,index) in dataList" :key="index" style="margin-bottom: 20rpx;">
							<view class="item" @click="itemClick(item)">
								<view class="item-logo">
									<image :src="item.Url" mode=""></image>
								</view>
								<view class="item-title">{{item.name}}</view>
								<view class="item-detail">
									<text class="one">{{item.integral}}</text>
									<text class="two">￥{{item.money}}</text>
								</view>
							</view>
						</u-col>
					</u-row>

				</view>
			</z-paging>
		</view>
	</view>
</template>
<script>
	import request from '../../http/request.js'
	// import custom from '../../components/custom-refresher/custom-refresher.vue'
	// import tabsview from '../../components/tabs-view/tabs-view.vue'
	export default {
		// components: {
		// 	custom,
		// 	tabsview
		// },
		data() {
			return {
				dataList: [],
				tabIndex: 0,
				refresherStatus: 0
			}
		},
		methods: {
			tabChange(index) {
				this.tabIndex = index;
				//当切换tab时请调用组件的reload方法，请勿直接调用：queryList方法！！
				this.$refs.paging.reload();
			},
			queryList(pageNo, pageSize) {
				request.queryList(pageNo, pageSize, this.tabIndex + 1, (data) => {
					this.$refs.paging.complete(data);
					this.firstLoaded = true;
				})
				//组件加载时会自动触发此方法，因此默认页面加载时会自动触发，无需手动调用
				//这里的pageNo和pageSize会自动计算好，直接传给服务器即可
				//模拟请求服务器获取分页数据，请替换成自己的网络请求
			},
			itemClick(item) {
				uni.navigateTo({
					url:"goods?id="+item.id
				})
				console.log('点击了', item.id);
			},
			
			// 积分明细
			integdetails(e){
				uni.navigateTo({
					url:'integdetails?id='+ e
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	page {
		height: 100%;
	}

	.wrap {
		height: 100%;
		padding: 0 36rpx;

		.header {
			margin-top: 40rpx;
			background: #28B07C;
			background: -webkit-linear-gradient(to bottom, #28B07C, #93f9b9);
			background: linear-gradient(to bottom, #28B07C, #93f9b9);
			width: 100%;
			height: 200rpx;
			border-top-left-radius: 5px;
			border-top-right-radius: 5px;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.name_item {
				.name_logo {
					width: 110rpx;
					height: 110rpx;
					float: left;
					margin-left: 25rpx;
				}

				.integral {
					float: left;
					margin-top: 20rpx;
					margin-left: 10rpx;

					.zong {
						color: #FFFFFF;
					}
				}
			}

			.jifen_item {
				background: #28B07C;
				background: -webkit-linear-gradient(to bottom, #28B07C, #ffffff);
				background: linear-gradient(to bottom, #28B07C, #ffffff);
				border-top-left-radius: 10px;
				border-bottom-left-radius: 10px;
				padding: 0 30rpx;
				height: 50rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 28rpx;
				color: #000;
			}
		}

		.content {
			height: 100%;

			.content_nav {
				margin-top: 40rpx;
				font-size: 32rpx;
			}
		}

		.item {
			width: 100%;
			border: 1px solid #E5E5E5;
			.item-logo {
				width: 100%;
				height: 270rpx;

				uni-image {
					width: 100%;
					height: 100%;
					border-top-left-radius: 5px;
					border-top-right-radius: 5px;
				}
				image{
					width: 100%;
					height: 100%;
					border-top-left-radius: 5px;
					border-top-right-radius: 5px;
				}
			}

			.item-title {
				margin-top: 15rpx;
				padding: 0 15rpx;
				color: #333333;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.item-detail {
				padding: 0 15rpx;
				margin-top: 15rpx;
				.one {
					color: #d8ae00;
					font-size: 30rpx;
				}

				.two {
					color: #999999;
					font-size: 26rpx;
				}
			}
		}
	}
</style>
